package com.amigo.online.provider.sync.handle.data.redis.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import com.amigo.online.common.param.result.UserInfo;
import com.amigo.online.provider.common.RedisKey;
import com.amigo.online.provider.sync.common.AbstractGlobalService;
import com.amigo.online.provider.sync.handle.data.redis.service.UserRedisService;

@Service
public class UserRedisServiceImpl extends AbstractGlobalService implements UserRedisService {

    @Autowired
    RedisTemplate<String, Object> redisTemplate;

    @Override
    public void insertObject(UserInfo newData) {
        redisTemplate.opsForHash().put("", 1, newData);
    }

    @Override
    public long updateObject(Long query, Integer update) {
        Long result = redisTemplate.opsForHash().delete(RedisKey.USER_REDIS_KEY, query);
        return result;
    }

    @Override
    public long deleteObject(Long query) {
        Long result = redisTemplate.opsForHash().delete(RedisKey.USER_REDIS_KEY, query);
        return result;
    }

}
